package com.example.notes;

import com.example.StrategyPattern.service.PayService;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * <pre>
 * 功能描述：
 * </pre>
 *
 * @author: 李明杰
 * @date: 2022/10/28 0:00
 */
@Component
public class GetExpectedBean2 implements ApplicationContextAware {

    private Map<String, PayService> payServiceMap;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        //2.   也可以用ApplicationContext 其他常用方法
        payServiceMap = applicationContext.getBeansOfType(PayService.class);
    }

    //===================方便测试添加的方法====================
    public Map<String, PayService> getPayServiceMap() {
        return payServiceMap;
    }
}
